<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>美兰数据文化馆与图书馆</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/huazhi/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/huazhi/css/public.css" media="all">
    <link rel="shortcut icon" href="<%=request.getContextPath()%>/huazhi/images/favicon.ico"/>
    <link rel="stylesheet" href="<%=request.getContextPath()%>/huazhi/css/formSelects-v4.css" media="all">
</head>
<style>
    /* 底部固定区域 */
    .layui-layout-admin .layui-footer {
        padding: 10px 0;
        text-align: center;
    }

    .layui-layout-admin .layui-footer {
        background-color: #fff;
    }

    .layui-form-label {
        width: 90px;
    }

    .layui-input-block {
        margin-left: 120px;
    }
</style>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-form">
                <input name="processlifetid" id="processlifetid" type="hidden">
                <div class="layui-row">
                    <fieldset class="layui-elem-field">
                        <legend>审批内容</legend>
                        <div class="layui-field-box">
                            <div class="layui-form-item">
                                <div class="layui-col-xs12">
                                    <div class="layui-col-xs6">
                                        <div class="layui-col-xs11">
                                            <div class="layui-inline"
                                                 style="margin-bottom: 0px;margin-right: 0px;width: 100%">
                                                <label class="layui-form-label">主题</label>
                                                <div class="layui-input-block">
                                                    <input type="text"
                                                           class="layui-input"
                                                           style="border-left:0px;border-right: 0px;border-top: 0px;"
                                                           name="name" id="name" lay-verify="name" disabled>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-col-xs11">
                                    <div class="layui-col-xs3">
                                        <div class="layui-block"
                                             style="margin-bottom: 0px;margin-right: 0px;width: 83%">
                                            <label class="layui-form-label">批号</label>
                                            <div class="layui-input-block">
                                                <div class="layui-input-inline" style="width: 78px;margin:0px;">
                                                    <input type="text" autocomplete="off" class="layui-input"
                                                           value="460108GB" name="display" disabled
                                                           style="border-left:0px;border-right: 0px;border-top: 0px;">
                                                </div>
                                                <div class="layui-input-block" style="margin-left:78px;width: 100%">
                                                    <input type="text" autocomplete="off" class="layui-input"
                                                           placeholder="" id="batchNumber" name="batchNumber"
                                                           style="padding-left:0px;border-left:0px;border-right: 0px;border-top: 0px;background-color:#fff;color:#6f6868; "
                                                           disabled>
                                                </div>
                                            </div>

                                        </div>
                                    </div>
                                </div>
                            </div>


                            <div class="layui-col-md12">
                                <div class="layui-row layui-col-space15">
                                    <div class="layui-col-sm6">
                                        <div class="layui-form">
                                            <div class="layui-card-header" style="padding: 0 10px;">明细
                                            </div>
                                            <div class="layui-tab-content" style="height: auto">
                                                <div class="layui-form-item" >
                                                    <div class="layui-col-xs11">
                                                        <label class="layui-form-label">订单号</label>
                                                        <div class="layui-input-block">
                                                            <input type="text" name="orderNumber" id="orderNumber"  class="layui-input"  disabled>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="layui-form-item">
                                                    <div class="layui-col-lg12">
                                                        <div class="layui-col-xs11">
                                                            <label class="layui-form-label">试剂名称</label>
                                                            <div class="layui-input-block">
                                                                <%--                                            <select name="suppliesName" lay-filter="suppliesName" id="suppliesName">--%>
                                                                <%--                                                <option value="">请选择</option>--%>
                                                                <%--                                            </select>--%>

                                                                <div class="layui-form">
                                                                    <select name="suppliesName" id="suppliesName"
                                                                            xm-select="suppliesName" xm-select-radio=""
                                                                            lay-verify="suppliesName"
                                                                            xm-select-search="">
                                                                        <%--                                                    <option value="1">北京</option>--%>
                                                                        <%--                                                    <option value="2">上海</option>--%>
                                                                        <%--                                                    <option value="3" selected="selected">广州</option>--%>
                                                                        <%--                                                    <option value="4" selected="selected">深圳</option>--%>
                                                                        <%--                                                    <option value="5" selected="selected">天津</option>--%>
                                                                        <%--                                                    <option value="6" selected="selected">杭州</option>--%>
                                                                    </select>
                                                                </div>

                                                            </div>
                                                        </div>
                                                        <div class="layui-col-xs1">
                                                            <div class="layui-form-mid layui-word-aux"
                                                                 style="color: red !important;padding: 10px !important;">
                                                                *
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="layui-form-item">
                                                    <div class="layui-col-lg12">
                                                        <div class="layui-col-xs11">
                                                            <label class="layui-form-label">库存数量</label>
                                                            <div class="layui-input-block">
                                                                <input type="text"
                                                                       autocomplete="off"
                                                                       class="layui-input" disabled id="quantity">
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="layui-form-item">
                                                    <div class="layui-col-lg12">
                                                        <div class="layui-col-xs11">
                                                            <label class="layui-form-label">领取数量</label>
                                                            <div class="layui-input-block">
                                                                <input type="text" name="inventory"
                                                                       autocomplete="off" placeholder="请输入领取数量"
                                                                       class="layui-input"
                                                                       id="inventory"
                                                                       oninput="value=value.replace(/[^\d]+/g,'')"
                                                                       maxlength="9" min="1">
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="layui-form-item">
                                                    <div class="layui-col-lg12" style="text-align: center">
                                                        <button class="layui-btn layui-btn-xs layui-bg-blue"
                                                                id="addSupplies">新增清单
                                                        </button>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-col-sm6">
                                        <div class="layui-card-header" style="padding: 0 10px;">领用清单
                                        </div>
                                        <div class="layui-tab-content" style="height: auto">
                                            <table class="layui-hide" id="collectRecordTable"
                                                   lay-filter="collectRecordTables"></table>
                                            <div id="laypage"></div>
                                        </div>
                                    </div>
                                </div>
                            </div>

                        </div>
                    </fieldset>
                </div>
                <div class="layui-row">
                    <div class="layui-form-item">
                        <fieldset class="layui-elem-field">
                            <legend>流程处理</legend>
                            <div class="layui-field-box">
                                <div class="layui-form">
                                    <div class="layui-form-item">
                                        <div class="layui-col-xs12">
                                            <div class="layui-col-xs6">
                                                <div class="layui-inline"
                                                     style="margin-bottom: 0px;margin-right: 0px;width: 83%">
                                                    <label class="layui-form-label">紧急程度</label>
                                                    <div class="layui-input-block">
                                                        <input type="radio"  name="urgent" value="紧急"
                                                               title="紧急" disabled>
                                                        <input type="radio"  name="urgent" value="急"
                                                               title="急" disabled>
                                                        <input type="radio"  name="urgent" value="一般"
                                                               title="一般"disabled>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-col-xs12">
                                            <div class="layui-col-xs6">
                                                <div class="layui-col-xs11">
                                                    <div class="layui-inline"
                                                         style="margin-bottom: 0px;margin-right: 0px;width: 100%">
                                                        <label class="layui-form-label">申请科室:</label>
                                                        <div class="layui-input-block">
                                                            <select name="departmenttid" xm-select="departmenttid"
                                                                    xm-select-search=""
                                                                    xm-select-radio="" id="departmenttid" lay-verify="departmenttid" disabled>
                                                            </select>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-col-xs12">
                                            <div class="layui-col-xs6">
                                                <div class="layui-col-xs11">
                                                    <div class="layui-inline"
                                                         style="margin-bottom: 0px;margin-right: 0px;width: 100%">
                                                        <label class="layui-form-label">审批人员:</label>
                                                        <div class="layui-input-block">
                                                            <select name="usertid" xm-select="usertid"
                                                                    xm-select-search=""
                                                                    xm-select-radio="" id="usertid" lay-verify="usertid" disabled>
                                                            </select>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-col-xs12">
                                            <div class="layui-col-xs3">
                                                <div class="layui-inline"
                                                     style="margin-bottom: 0px;margin-right: 0px;width: 100%">
                                                    <label class="layui-form-label">申请人:</label>
                                                    <div class="layui-input-block">
                                                        <input type="text" value="${user.name}"
                                                               class="layui-input" name="application"
                                                               style="border-left:0px;border-right: 0px;border-top: 0px;"
                                                               disabled>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <input type="hidden" name="type" value="2">
                                    <div class="layui-form-item">
                                        <div class="layui-col-xs12">
                                            <div class="layui-col-xs3">
                                                <div class="layui-inline"
                                                     style="margin-bottom: 0px;margin-right: 0px;width: 100%">
                                                    <label class="layui-form-label">申请时间:</label>
                                                    <div class="layui-input-block">
                                                        <input type="text" id="datetime" name="datetime"
                                                               autocomplete="off"
                                                               class="layui-input"
                                                               readonly=""
                                                               style="border-left:0px;border-right: 0px;border-top: 0px;" lay-verify="datetime" disabled>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-col-xs12">
                                            <div class="layui-col-xs6">
                                                <div class="layui-col-xs11">
                                                    <div class="layui-inline"
                                                         style="margin-bottom: 0px;margin-right: 0px;width: 100%">
                                                        <label class="layui-form-label">申请人意见:</label>
                                                        <div class="layui-input-block">
                                                            <textarea name="opinion" class="layui-textarea" id="opinion"></textarea>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-col-xs12">
                                            <div class="layui-col-xs6">
                                                <div class="layui-col-xs11">
                                                    <div class="layui-inline"
                                                         style="margin-bottom: 0px;margin-right: 0px;width: 100%">
                                                        <label class="layui-form-label">备注:</label>
                                                        <div class="layui-input-block">
                                                            <textarea name="remarks" class="layui-textarea" id="remarks"></textarea>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </fieldset>
                    </div>
                </div>
                <div class="layui-form-item layui-layout-admin">
                    <div class="layui-footer" style="left: 0;padding: 0px;">
                        <button class="layui-btn" lay-submit lay-filter="*" id="pushButton">提交申请</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="chemicalApplicationOperation">
    <div class="layui-inline" lay-event="add" title="添加">
        <i class="layui-icon layui-icon-add-1"></i>
    </div>
</script>
<script type="text/html" id="table-inventory">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script src="<%=request.getContextPath()%>/huazhi/lib/jquery-3.4.1/jquery-3.4.1.min.js"></script>
<script src="<%=request.getContextPath()%>/huazhi/lib/layui-v2.5.5/layui.all.js"></script>
<script src="<%=request.getContextPath()%>/huazhi/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
    function child(processlifetid) {
        layui.use(['form', 'laydate', 'formSelects','laypage'], function () {
            var $ = layui.$
                , table = layui.table
                , layer = layui.layer,
                form = layui.form,
                laydate = layui.laydate
                , formSelects = layui.formSelects,
                laypage=layui.laypage;

            $.ajax({
                type: "post",
                url: "<%=request.getContextPath()%>/rest/process/getChemicalList",
                dataType: "json",
                async: false,
                success: function (msg) {
                    formSelects.data('suppliesName', 'local', {
                        arr: msg
                    });

                }
            })

            formSelects.on('suppliesName', function(id, vals, val, isAdd, isDisabled){
                if (val.value == "") {
                    $("#quantity").val("");
                } else {
                    if(isAdd){
                        $.ajax({
                            type: "post",
                            url: "<%=request.getContextPath()%>/rest/process/getChemicalByTid",
                            dataType: "json",
                            data: "tid=" + val.value,
                            async: false,
                            success: function (msg) {
                                var quantity = msg.quantity;
                                $("#quantity").val(parseInt(quantity));
                            }
                        })
                    }else{
                        $("#quantity").val("");
                    }
                }

                //如果return false, 那么将取消本次操作
            });


            //监听工具条
            table.on('tool(collectRecordTables)', function (obj) {  //表格的lay-filter="userlists"
                var data = obj.data; //获得当前行所有数据
                var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
                var tr = obj.tr; //获得当前行 tr 的DOM对象
                if (obj.event === 'del') {
                    del(data, obj)
                }
            });

            function del(data, obj) {
                layer.confirm('确定删除此数据', {icon: 3, title: '提示信息', shade: 0.6}, function (index) {
                    layer.close(index);
                    layer.msg('删除中，请稍候', {icon: 16, time: false, shade: 0.6});
                    setTimeout(function () {
                        //向服务端发送删除指令
                        $.ajax({
                            type: "post",
                            url: "<%=request.getContextPath()%>/rest/process/deleteCollectRecord",
                            data: "tid=" + data.tid,
                            dataType: "json",
                            async: false,
                            success: function (msg) {
                                layer.close(index);
                                if (msg.data == true) {
                                    layer.msg('删除成功');
                                    var yyy=formSelects.value('suppliesName', 'valStr');

                                    if(yyy==""){

                                    }else {
                                        $("#quantity").val( msg.count);
                                    }
                                    obj.del();
                                } else {
                                    layer.msg(msg.errorMsg);
                                }
                            }
                        })
                    }, 2000);
                });
            }


            $("#addSupplies").click(function () {

                var suppliesTid = formSelects.value('suppliesName', 'valStr');
                // var suppliesTid = $("#suppliesName").val()
                if (suppliesTid == "") {
                    // $(".xm-hide-input").addClass("layui-form-danger");
                    // $(".xm-hide-input").focus();
                    layer.msg('请选择名称', {icon: 5, shift: 6});
                    return false
                } else {
                    var inventory = $("#inventory").val()
                    if (inventory == "") {
                        var numbersId = document.getElementById("inventory");
                        numbersId.setAttribute("class", "layui-input layui-form-danger");
                        numbersId.focus();
                        layer.msg('请输入领取数量', {icon: 5, shift: 6});
                    } else {
                        var quantity = $("#quantity").val();
                        var random1 =$("#orderNumber").val();

                        if (quantity == 0) {
                            layer.msg('库存数量已用完', {icon: 5, shift: 6});
                        } else {
                            if (parseInt(inventory) == 0) {
                                var numbersId = document.getElementById("inventory");
                                numbersId.setAttribute("class", "layui-input layui-form-danger");
                                numbersId.focus();
                                layer.msg('请输入领取数量', {icon: 5, shift: 6});
                            } else {
                                if (parseInt(quantity) >= parseInt(inventory)) {
                                    $.ajax({
                                        type: "post",
                                        url: "<%=request.getContextPath()%>/rest/process/addChemicalCollect",
                                        dataType: "json",
                                        async: false,
                                        data: "suppliesTid=" + suppliesTid + "&inventory=" + inventory + "&random=" + random1,
                                        success: function (msg) {
                                            if (msg = true) {
                                                layer.msg('添加成功');
                                                $("#quantity").val("");
                                                $("#inventory").val("")
                                                // $("#suppliesName").val("");
                                                // form.render('select');
                                                formSelects.value('suppliesName', []);
                                                $("#curnum").val("1");
                                                table.reload('collectRecordTable', { //表格的id
                                                    where: {
                                                        random: random1,
                                                        page: 1,
                                                        limit: 10,
                                                    },
                                                    text: {
                                                        none: '暂无相关数据' //默认：无数据。注：该属性为 layui 2.2.5 开始新增
                                                    }
                                                })
                                            } else {
                                                layer.msg(msg.errorMsg);
                                            }
                                        }
                                    })
                                } else {
                                    layer.msg('领取数量大于库存数量,请重新输入领取数量', {icon: 5, shift: 6});
                                }
                            }
                        }
                    }
                }

            });



            $("#processlifetid").val(processlifetid)

            $.ajax({
                type: "post",
                url: "<%=request.getContextPath()%>/rest/process/getProcessLifeByTid",
                dataType: "json",
                async: false,
                data: 'processlifetid=' + processlifetid,
                success: function (msg) {

                    $("#opinion").val(msg.opinion);
                    $("#remarks").val(msg.remarks);

                    $.ajax({
                        type: "post",
                        url: "<%=request.getContextPath()%>/rest/process/getProcessAllByTid",
                        dataType: "json",
                        async: false,
                        data: 'processalltid=' + msg.allprocesstid,
                        success: function (obj) {
                            $("#name").val(obj.title);

                            $("input:radio[value='2']").attr('checked','true');
                            $("#batchNumber").val(obj.batchnumber);
                            $("#startmanname").val(obj.startmanname);
                            $("#datetime").val(obj.starttimestring);
                            form.val("component-form-element", obj)
                            form.render('radio');

                            $.ajax({
                                type: "post",
                                url: "<%=request.getContextPath()%>/rest/process/getRands",
                                dataType: "json",
                                async: false,
                                data:"number="+obj.batchnumber,
                                success: function (msg) {
                                    $("#orderNumber").val(msg);
                                    var limitcount = 10;
                                    table.render({
                                        elem: '#collectRecordTable'
                                        , url: "<%=request.getContextPath()%>/rest/process/getListCollectRecord"
                                        , title: "领用清单表",
                                        height: 'full-450'
                                        , page: false
                                        // , toolbar: '#suppliesCollectOperation'
                                        , limit: limitcount
                                        , text: {
                                            none: '暂无相关数据' //默认：无数据。注：该属性为 layui 2.2.5 开始新增
                                        },
                                        where: {"random": msg},
                                        skin: 'line',
                                        defaultToolbar: ['filter', 'print']
                                        // ,skin: 'line' //表格风格
                                        , cols: [[
                                            // {type: 'checkbox'}
                                            {title: 'ID', width: 70, sort: true, fixed: 'left', type: 'numbers'}
                                            , {field: 'suppliesname', title: '试剂名称', sort: true}
                                            , {field: 'quantity', title: '领用数量', sort: true}
                                            , {title: '操作', toolbar: '#table-inventory', fixed: "right", align: "center", width: 200}
                                        ]],
                                        done: function (res, curr, count) {
                                            var curnum = $("#curnum").val();
                                            $('.layui-table-fixed-r').removeClass('layui-hide');//列固定右侧
                                            laypage.render({
                                                elem: 'laypage'
                                                , first: '首页'
                                                , last: '尾页'
                                                , groups: 5
                                                , count: count
                                                , curr: curnum
                                                , limit: limitcount
                                                , layout: ['prev', 'page', 'next', 'skip', 'count', 'limit']
                                                , limits: [10, 15, 20]
                                                , jump: function (obj, first) {
                                                    if (!first) {
                                                        curnum = obj.curr;
                                                        $("#curnum").val(curnum)
                                                        limitcount = obj.limit;
                                                        table.reload('collectRecordTable', { //表格的id
                                                            where: {
                                                                page: curnum,
                                                                limit: limitcount
                                                            }
                                                        })
                                                    }
                                                }
                                            })
                                        }
                                    });

                                }
                            });


                            $.ajax({
                                type: "post",
                                url: "<%=request.getContextPath()%>/rest/process/getExamineAgainUser",
                                dataType: "json",
                                async: false,
                                data: "departmenttid=" + obj.dep+"&processlifetid="+processlifetid+'&processlisttid=' + msg.processlisttid,
                                success: function (obj) {
                                    formSelects.data('usertid', 'local', {
                                        arr: obj
                                    });
                                }
                            })

                        }
                    })


                    $.ajax({
                        type: "post",
                        url: "<%=request.getContextPath()%>/rest/process/getExamineAgainDep",
                        dataType: "json",
                        async: false,
                        data: 'processalltid=' + msg.allprocesstid,
                        success: function (obj) {
                            formSelects.data('departmenttid', 'local', {
                                arr: obj
                            });
                        }
                    })

                }
            })




            table.on('toolbar(chemicalApplicationTables)', function (obj) {
                var checkStatus = table.checkStatus(obj.config.id)
                    , data = checkStatus.data, //获取选中的数据
                    newsId = [];
                switch (obj.event) {
                    case 'add':
                        var clocess = "1";
                        var index = layer.open({
                            title: "添加",
                            type: 2,
                            content: '<%=request.getContextPath()%>/rest/getRoute?type=instrument&url=chemicalApplication_add',
                            maxmin: true,
                            area: ['90%', '91%'],
                            //是否显示右上角关闭图标，默认为1，显示
                            anim: 4,
                            shade: 0.6,
                            skin: 'layui-layer-molv',
                            resize: true,
                            cancel: function (index, layero) {
                                layer.close(index)
                                clocess = "2"
                                return false;
                            },
                            success: function (layero, index) {  //当你需要在层创建完毕时即执行一些语句，可以通过该回调 想相当于吧值转到子界面
                                var iframe = window['layui-layer-iframe' + index];
                                iframe.child($("#batchNumber").val())
                            },
                            end: function () {
                                if (clocess == "2") {

                                } else {
                                    var  batchNumber=$("#batchNumber").val();
                                    table.reload('chemicalApplicationTable', { //表格的id
                                        where: {
                                            key: "",
                                            batchNumber: batchNumber
                                        },
                                        text: {
                                            none: '暂无相关数据' //默认：无数据。注：该属性为 layui 2.2.5 开始新增
                                        }
                                    })
                                }
                                return false;
                            }
                        });
                        break;
                }
                ;
            });


            //第一种方法添加用户
            form.on('submit(*)', function (data) {
                var field = data.field//当前容器的全部表单字段，名值对形式：{name: value}
                data.field.answer = "yes";

                var orderNumber = field.orderNumber;
                var flag = true;
                $.ajax({
                    type: "post",
                    url: "<%=request.getContextPath()%>/rest/process/detailedListByOrderNumber",
                    data: "orderNumber=" + orderNumber,
                    dataType: "json",
                    async: false,
                    success: function (obj) {
                        flag = obj;
                    }
                })
                if (!flag) {
                    layer.msg('请添加领用清单', {icon: 5, shift: 6});
                    return false;
                }

                var index = layer.msg('数据提交中，请稍候', {icon: 16, time: false, shade: 0.6});
                $("#pushButton").addClass("layui-btn layui-btn-disabled").prop("disabled", true);
                $.ajax({
                    type: "post",
                    url: "<%=request.getContextPath()%>/rest/process/agreeProcesslife",
                    data: field,
                    dataType: "json",
                    async: false,
                    success: function (obj) {
                        setTimeout(function () {
                            layer.close(index);
                            if (obj = true) {
                                layer.msg('提交成功');

                            } else {
                                layer.msg(obj.errorMsg);
                            }
                        }, 2000);
                        setTimeout(function () {
                            var indexs = parent.layer.getFrameIndex(window.name);//获取当前弹出层的层级
                            parent.layer.close(indexs);//关闭弹出层
//                        window.parent.location.reload();//刷新父页面
                        }, 4000);
                    }
                })
                return false;
            });

        });
    }
</script>
</body>
</html>